mod cpp_bindings;

use cxx::{CxxString, CxxVector};
use std::ffi::CString;

#[cxx::bridge]
mod ffi {
    unsafe extern "C++" {
        include!("./cpp/include/my_cpp_lib.h");

        type MyCppClass;

        fn new_my_cpp_class() -> UniquePtr<MyCppClass>;
        fn set_message(self: Pin<&mut MyCppClass>, message: &CxxString);
        fn get_message(self: &MyCppClass) -> CxxString;
    }
}

fn main() {
    let mut cpp_obj = ffi::new_my_cpp_class();
    let message = CString::new("Hello from Rust!").unwrap();
    let cxx_message = CxxString::from(message);

    ffi::set_message(cpp_obj.pin_mut(), &cxx_message);

    let retrieved_message = ffi::get_message(&cpp_obj);
    println!("Message from C++: {}", retrieved_message);
}